package com.mvc.server.miaosha.service;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.mvc.server.dynamic.ds.config.DataSource;
import com.mvc.server.miaosha.dao.UserDao;
import com.mvc.server.miaosha.pojo.User;

@Service
public class UserService {
	
	@Resource
	private UserDao userDao;
	
	@Resource
	private GoodsService goodsService;
	
	@DataSource("slave2")
	@Transactional
	public User getById(int id) {
		
		 return userDao.getById(id);
	}
	
	@DataSource("slave1")
	@Transactional
	public int insert(User user) {
		
		int insert = userDao.insert(user);
		
		return insert;
	}
	
	@DataSource("slave1")
	public int update(User user) {
		
		int update = userDao.update(user);
		
		return update;
	}

}
